//
//  BarCodeView.m
//  CorporateUniversity
//
//  Created by macbook on 15/10/30.
//  Copyright © 2015年 CompanyOfHanJun. All rights reserved.
//

#import "BarCodeView.h"

#define KDeepColor [[UIColor blackColor]colorWithAlphaComponent:0.5]

#define KShallowColor [UIColor clearColor];


@implementation BarCodeView
{
    CGFloat _topSpace;
    
    CGFloat _bottomSpace;
    
    CGFloat _middleViewWidth;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    
    if (self)
    {
        
        _middleViewWidth = ScreenWidth-KLeftSpace*2;
        
        _topSpace = (ScreenHeight-(ScreenWidth - KLeftSpace*2))/2;
        
        _bottomSpace = (ScreenHeight-(ScreenWidth - KLeftSpace*2))/2;
        
        [self addTopView];
        
        [self addLeftView];
        
        [self addMiddleView];
        
        [self addRightView];
        
        [self addBottomView];
        
    }
    return self;
}
-(void)addTopView
{
    UIView *topView=[[UIView alloc]initWithFrame:CGRectMake(0, 0,ScreenWidth,_topSpace)];
    
    topView.backgroundColor=KDeepColor;
    
    [self addSubview:topView];
}

-(void)addLeftView
{
    UIView *leftView=[[UIView alloc]initWithFrame:CGRectMake(0, _topSpace, KLeftSpace,_middleViewWidth)];
    
    leftView.backgroundColor=KDeepColor;
    
    [self addSubview:leftView];
}

-(void)addRightView
{
    UIView *rightView=[[UIView alloc]initWithFrame:CGRectMake(ScreenWidth-KLeftSpace, _topSpace, KLeftSpace, _middleViewWidth)];
    
    rightView.backgroundColor=KDeepColor;
    
    [self addSubview:rightView];
}

-(void)addBottomView
{
    UIView *bottomView=[[UIView alloc]initWithFrame:CGRectMake(0,_topSpace+_middleViewWidth,ScreenWidth,_bottomSpace)];
    
    bottomView.backgroundColor=KDeepColor;
    
    [self addSubview:bottomView];
}

-(void)addMiddleView
{
    UIView *middleView=[[UIView alloc]initWithFrame:CGRectMake(KLeftSpace,_topSpace, _middleViewWidth,_middleViewWidth)];
    
    middleView.backgroundColor=KShallowColor;
    
    middleView.layer.borderWidth=1.0;
    
    middleView.layer.borderColor=[[UIColor greenColor]CGColor];
    
    [self addSubview:middleView];
    
    _middleView=middleView;
}

@end
